package com.dhsc.service.impl.wskh;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.dhsc.domain.ywzx.wskh.WskhTsshVo;
import com.dhsc.domain.yypt.LayuiTableVo;
import com.dhsc.domain.yypt.ResponseObject;
import com.dhsc.exception.MyException;
import com.dhsc.local.dao.wskh.IWskhTsshDao;
import com.dhsc.service.wskh.IWskhTsshService;
import com.github.pagehelper.PageInfo;
import com.github.pagehelper.page.PageMethod;

import lombok.extern.slf4j.Slf4j;

@Service
@Slf4j
public class WskhTsshServiceImpl implements IWskhTsshService{

	@Autowired
	private IWskhTsshDao twskhtsshDao;

	@Override
	public LayuiTableVo queryWskhTsshByAll(WskhTsshVo y) {
		LayuiTableVo obj = new LayuiTableVo();
		try{
			PageMethod.startPage(y.getPage(),y.getLimit());
			List<WskhTsshVo> list = twskhtsshDao.queryWskhTsshByAll(y);
			PageInfo<WskhTsshVo> pageInfo = new PageInfo<>(list);

			obj.setData(list);
			obj.setMsg("");
			obj.setCount(pageInfo.getTotal());
			obj.setCode(0);
		}catch(Exception e){
			log.error("查询网上开户特殊审核出错", e);
			throw new MyException("查询网上开户特殊审核出错",e);
		}
		return obj;
	}
	
	@Override
	public LayuiTableVo queryZdzhYwhbByAll(WskhTsshVo y) {
		LayuiTableVo obj = new LayuiTableVo();
		try{
			PageMethod.startPage(y.getPage(),y.getLimit());
			List<WskhTsshVo> list = twskhtsshDao.queryZdzhYwhbByAll(y);
			PageInfo<WskhTsshVo> pageInfo = new PageInfo<>(list);

			obj.setData(list);
			obj.setMsg("");
			obj.setCount(pageInfo.getTotal());
			obj.setCode(0);
		}catch(Exception e){
			log.error("查询中登账户业务回报(网上开户特殊审核)出错", e);
			throw new MyException("查询中登账户业务回报(网上开户特殊审核)出错",e);
		}
		return obj;
	}
	
    @Override
    public ResponseObject addTsshhfjg(WskhTsshVo f) {
        ResponseObject obj = new ResponseObject();
        try {
        	twskhtsshDao.addTsshHfjg(f);
            obj.setStatus(200);
        }catch (Exception e){
            log.error("保存网上开户特殊审核回访结果出错",e);
			throw new MyException("保存网上开户特殊审核回访结果出错",e);
        }
        return obj;
    }
}